|
1
|
|
|
/* |
|
2
|
|
|
* Circles - Bring cloud-users closer together. |
|
3
|
|
|
* |
|
4
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
5
|
|
|
* later. See the COPYING file. |
|
6
|
|
|
* |
|
7
|
|
|
* @author Maxence Lange <[email protected]> |
|
8
|
|
|
* @copyright 2017 |
|
9
|
|
|
* @license GNU AGPL version 3 or any later version |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
14
|
|
|
* License, or (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
/** global: OC */ |
|
27
|
|
|
/** global: OCA */ |
|
28
|
|
|
/** global: Notyf */ |
|
29
|
|
|
|
|
30
|
|
|
/** global: nav */ |
|
31
|
|
|
/** global: elements */ |
|
32
|
|
|
/** global: curr */ |
|
33
|
|
|
/** global: api */ |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
var nav = { |
|
37
|
|
|
|
|
38
|
|
|
displayCirclesList: function (type) { |
|
39
|
|
|
|
|
40
|
|
|
curr.circlesType = type; |
|
41
|
|
|
curr.searchCircle = ''; |
|
42
|
|
|
curr.searchUser = ''; |
|
43
|
|
|
|
|
44
|
|
|
curr.circle = 0; |
|
45
|
|
|
curr.circleLevel = 0; |
|
46
|
|
|
|
|
47
|
|
|
elements.navigation.show('slide', 800); |
|
48
|
|
|
elements.emptyContent.show(800); |
|
49
|
|
|
elements.mainUI.fadeOut(800); |
|
50
|
|
|
|
|
51
|
|
|
elements.circlesSearch.val(''); |
|
52
|
|
|
elements.addMember.val(''); |
|
53
|
|
|
|
|
54
|
|
|
this.resetCirclesTypeSelection(type); |
|
55
|
|
|
elements.resetCirclesList(); |
|
56
|
|
|
api.listCircles(type, actions.listCirclesResult); |
|
|
|
|
|
|
57
|
|
|
}, |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
resetCirclesTypeSelection: function (type) { |
|
61
|
|
|
elements.circlesList.children('div').removeClass('selected'); |
|
62
|
|
|
elements.circlesList.children().each(function () { |
|
63
|
|
|
if ($(this).attr('circle-type') == type.toLowerCase()) { |
|
64
|
|
|
$(this).addClass('selected'); |
|
65
|
|
|
} |
|
66
|
|
|
}); |
|
67
|
|
|
}, |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* |
|
71
|
|
|
* @param display |
|
72
|
|
|
*/ |
|
73
|
|
|
displayOptionsNewCircle: function (display) { |
|
74
|
|
|
if (display) { |
|
75
|
|
|
elements.newType.fadeIn(300); |
|
76
|
|
|
elements.newSubmit.fadeIn(500); |
|
77
|
|
|
elements.newTypeDefinition.fadeIn(700); |
|
78
|
|
|
} |
|
79
|
|
|
else { |
|
80
|
|
|
elements.newType.fadeOut(700); |
|
81
|
|
|
elements.newSubmit.fadeOut(500); |
|
82
|
|
|
elements.newTypeDefinition.fadeOut(300); |
|
83
|
|
|
} |
|
84
|
|
|
}, |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
displayMembers: function (members) { |
|
88
|
|
|
|
|
89
|
|
|
elements.mainUIMembers.emptyTable(); |
|
90
|
|
|
if (members === null) { |
|
91
|
|
|
elements.mainUIMembers.hide(200); |
|
92
|
|
|
return; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
elements.mainUIMembers.show(200); |
|
96
|
|
|
for (var i = 0; i < members.length; i++) { |
|
97
|
|
|
elements.mainUIMembers.append(elements.generateTmplMember(members[i])); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
this.displayMembersAsModerator(); |
|
101
|
|
|
}, |
|
102
|
|
|
|
|
103
|
|
|
|
|
104
|
|
|
displayMembersAsModerator: function () { |
|
105
|
|
|
if (curr.circleLevel >= 6) { |
|
106
|
|
|
|
|
107
|
|
|
elements.mainUIMembers.children("[member-level!='9']").each(function () { |
|
108
|
|
|
$(this).children('.delete').show(0); |
|
109
|
|
|
|
|
110
|
|
|
var member = $(this).attr('member-id'); |
|
111
|
|
|
$(this).children('.delete').on('click', function () { |
|
112
|
|
|
api.removeMember(curr.circle, member, actions.removeMemberResult); |
|
|
|
|
|
|
113
|
|
|
}); |
|
114
|
|
|
}); |
|
115
|
|
|
} |
|
116
|
|
|
}, |
|
117
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
displayMembersInteraction: function (details) { |
|
120
|
|
|
if (details.user.level < 6) { |
|
121
|
|
|
elements.addMember.hide(); |
|
122
|
|
|
} else { |
|
123
|
|
|
elements.addMember.show(); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
this.displayNonMemberInteraction(details); |
|
127
|
|
|
|
|
128
|
|
|
if (details.user.level == 9) { |
|
129
|
|
|
elements.joinCircle.hide(); |
|
130
|
|
|
elements.leaveCircle.hide(); |
|
131
|
|
|
return; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
if (details.user.level >= 1) { |
|
135
|
|
|
elements.joinCircle.hide(); |
|
136
|
|
|
elements.leaveCircle.show(); |
|
137
|
|
|
} |
|
138
|
|
|
}, |
|
139
|
|
|
|
|
140
|
|
|
displayNonMemberInteraction: function (details) { |
|
141
|
|
|
elements.joinCircleAccept.hide(); |
|
142
|
|
|
elements.joinCircleReject.hide(); |
|
143
|
|
|
elements.joinCircleRequest.hide(); |
|
144
|
|
|
elements.joinCircleInvite.hide(); |
|
145
|
|
|
|
|
146
|
|
|
if (details.user.status == 'Invited') { |
|
147
|
|
|
this.displayInvitedMemberInteraction(); |
|
148
|
|
|
return; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
if (details.user.status == 'Requesting') { |
|
152
|
|
|
this.displayRequestingMemberInteraction(); |
|
153
|
|
|
return; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
elements.joinCircle.show(); |
|
157
|
|
|
elements.leaveCircle.hide(); |
|
158
|
|
|
}, |
|
159
|
|
|
|
|
160
|
|
|
displayInvitedMemberInteraction: function () { |
|
161
|
|
|
elements.joinCircleInvite.show(); |
|
162
|
|
|
elements.joinCircleAccept.show(); |
|
163
|
|
|
elements.joinCircleReject.show(); |
|
164
|
|
|
elements.joinCircle.hide(); |
|
165
|
|
|
elements.leaveCircle.hide(); |
|
166
|
|
|
}, |
|
167
|
|
|
|
|
168
|
|
|
displayRequestingMemberInteraction: function () { |
|
169
|
|
|
elements.joinCircleRequest.show(); |
|
170
|
|
|
elements.joinCircle.hide(); |
|
171
|
|
|
elements.leaveCircle.show(); |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
}; |
|
175
|
|
|
|
|
176
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.